package database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Conexao implements IConexao {
	
	private static String DRIVE = "sun.jdbc.odbc.JdbcOdbcDriver";
	private static String PATH_BANCO = "DAO_0003/src/database/dao_0003.mdb";
	private static String URL_ACCESS_1 ="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=../";
	private static String URL_ACCESS_2 =";DriverID=22;READONLY=true}";
	private static String USER = "";
	private static String PASSWORD = "";
	
	private Connection con;
	
	public Conexao(){
	}

	public void abrirConexao() throws ClassNotFoundException, SQLException {
		Class.forName(DRIVE);
		con = DriverManager.getConnection(URL_ACCESS_1+PATH_BANCO+URL_ACCESS_2,USER,PASSWORD);
	}

	public void fecharConexao() throws SQLException {
        if(con != null)
            con.close();
	}

	public Connection getConexao() {
		return con;
	}

}
